package com.ruoyi.web.controller.mall.mallShopBank.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.web.controller.mall.mallShopBank.domain.MallShopBank;
import com.ruoyi.web.controller.mall.mallShopBank.service.IMallShopBankService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 店铺银行Controller
 * 
 * @author ruoyi
 * @date 2021-01-18
 */
@Controller
@RequestMapping("/mall/mallShopBank")
public class MallShopBankController extends BaseController
{
    private String prefix = "mall/mallShopBank";

    @Autowired
    private IMallShopBankService mallShopBankService;

//    @RequiresPermissions("mall:mallShopBank:view")
    @GetMapping()
    public String mallShopBank()
    {
        return prefix + "/mallShopBank";
    }

    /**
     * 查询店铺银行列表
     */
//    @RequiresPermissions("mall:mallShopBank:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(MallShopBank mallShopBank)
    {
        startPage();
        List<MallShopBank> list = mallShopBankService.selectMallShopBankList(mallShopBank);
        return getDataTable(list);
    }

    /**
     * 导出店铺银行列表
     */
//    @RequiresPermissions("mall:mallShopBank:export")
    @Log(title = "店铺银行", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(MallShopBank mallShopBank)
    {
        List<MallShopBank> list = mallShopBankService.selectMallShopBankList(mallShopBank);
        ExcelUtil<MallShopBank> util = new ExcelUtil<MallShopBank>(MallShopBank.class);
        return util.exportExcel(list, "mallShopBank");
    }

    /**
     * 新增店铺银行
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存店铺银行
     */
//    @RequiresPermissions("mall:mallShopBank:add")
    @Log(title = "店铺银行", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(MallShopBank mallShopBank)
    {
        return toAjax(mallShopBankService.insertMallShopBank(mallShopBank));
    }

    /**
     * 修改店铺银行
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        MallShopBank mallShopBank = mallShopBankService.selectMallShopBankById(id);
        mmap.put("mallShopBank", mallShopBank);
        return prefix + "/edit";
    }

    /**
     * 修改保存店铺银行
     */
//    @RequiresPermissions("mall:mallShopBank:edit")
    @Log(title = "店铺银行", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(MallShopBank mallShopBank)
    {
        return toAjax(mallShopBankService.updateMallShopBank(mallShopBank));
    }

    /**
     * 删除店铺银行
     */
//    @RequiresPermissions("mall:mallShopBank:remove")
    @Log(title = "店铺银行", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String[] ids)
    {
        return toAjax(mallShopBankService.deleteMallShopBankByIds(ids));
    }
}
